<template>
  <div class="app-container">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input size="small" v-model="queryItems[0].value" :placeholder="$t('name')" clearable/>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" @click="getDataList()">{{ $t('query') }}</el-button>
      </el-form-item>
<!--      <el-form-item>-->
<!--        <el-button v-if="$hasPermission('sys:role:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>-->
<!--      </el-form-item>-->
<!--      <el-form-item>-->
<!--        <el-button v-if="$hasPermission('sys:role:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>-->
<!--      </el-form-item>-->
    </el-form>
    <el-table
      v-loading="dataListLoading"
      :data="dataList"
      border
      size="mini"
      stripe
      @selection-change="dataListSelectionChangeHandle"
      style="width: 100%;">
<!--      <el-table-column type="selection" header-align="center" align="center" width="50"/>-->
      <el-table-column prop="name" :label="$t('name')"  header-align="center" align="center"/>
        <el-table-column prop="mobile" :label="$t('mobile')"  align="center">
            <template slot-scope="scope">
                <span v-if="scope.row.mobile != null && scope.row.mobile != '' ">
                    {{scope.row.mobile.replace(/^(.{4})(?:\d+)(.{3})$/, "$1****$2")}}
                </span>
            </template>
        </el-table-column>
        <el-table-column prop="identity" :label="$t('identity')" header-align="center"  align="center">
            <template slot-scope="scope">
                <span v-if="scope.row.identity != null && scope.row.identity != '' ">
                    {{scope.row.identity.replace(/^(.{6})(?:\d+)(.{4})$/, "$1****$2")}}
                </span>
            </template>
        </el-table-column>
      <el-table-column prop="realnameStatus" :label="$t('customer.realnameStatus')" header-align="center" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.realnameStatus === 0" size="mini" type="danger">{{ $t('customer.realnameStatus0') }}</el-tag>
          <el-tag v-else-if="scope.row.realnameStatus === 1" size="mini" type="success">{{ $t('customer.realnameStatus1') }} </el-tag>
          <el-tag v-else-if="scope.row.realnameStatus === 2" size="mini" type="warning">{{ $t('customer.realnameStatus2') }} </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="realnameType" :label="$t('customer.realnameType')" header-align="center" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.realnameType === 1" size="mini" type="success">{{ $t('customer.realnameType1') }}</el-tag>
          <el-tag v-else-if="scope.row.realnameType === 2" size="mini" type="success">{{ $t('customer.realnameType2') }} </el-tag>
          <el-tag v-else-if="scope.row.realnameType === 3" size="mini" type="success">{{ $t('customer.realnameType3') }} </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" :label="$t('createTime')" sortable="custom" header-align="center" align="center" width="180"/>
      <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
        <template slot-scope="scope">
<!--          <el-button v-if="$hasPermission('sys:role:update')" type="text" size="mini" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>-->
          <el-button v-hasPermi="['sys:customer:delete']" type="text" size="mini" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"/>
    <!-- 分页 -->
    <el-pagination
      slot="footer"
      :current-page="page"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="limit"
      :total="total"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="pageSizeChangeHandle"
      @current-change="pageCurrentChangeHandle">
    </el-pagination>
  </div>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './customer-add-or-update'
export default {
  mixins: [ mixinViewModule ],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/manager/customer/page',
        getDataListIsPage: true,
        deleteURL: '/manager/customer/delete',
        deleteIsBatch: true
      },
      dataForm: {

      },
      queryItems: [
        {
          field: 'name',
          as: 'LIKE',
          value: ''
        }
      ],
      order: 'DESC',
      orderField: 'createTime'
    }
  },
  components: {
    AddOrUpdate
  },
  methods:{

  }
}
</script>
